home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRNOMY / AA_51.ZIP / RSTAR.C < prev    next >
C/C++ Source or Header  |  1993-02-09  |  3KB  |  139 lines

  1. /* This program reduces catalogue coordinates of a star
  2.  * to apparent place.
  3.  *
  4.  * - S. L. Moshier, November, 1987
  5.  */
  6.  
  7. #include "kep.h"
  8.  
  9. int rstar( el )
  10. struct star *el;
  11. {
  12. double p[3], q[3], e[3], m[3], temp[3], polar[3];
  13. double T, vpi, epoch;
  14. double cosdec, sindec, cosra, sinra;
  15. int i;
  16. double log();
  17.  
  18.  
  19. /* Convert from RA and Dec to equatorial rectangular direction
  20.  */
  21. loop:
  22. cosdec = cos( el->dec );
  23. sindec = sin( el->dec );
  24. cosra = cos( el->ra );
  25. sinra = sin( el->ra );
  26. q[0] = cosra * cosdec;
  27. q[1] = sinra * cosdec;
  28. q[2] = sindec;
  29.  
  30. /* space motion */
  31. vpi = 21.094952663 * el->v * el->px;
  32. m[0] =    -el->mura * cosdec * sinra
  33.     - el->mudec * sindec * cosra
  34.     +       vpi * q[0];
  35.  
  36. m[1] =     el->mura * cosdec * cosra
  37.     - el->mudec * sindec * sinra
  38.     +       vpi * q[1];
  39.  
  40. m[2] =    el->mudec * cosdec
  41.     +       vpi * q[2];
  42.  
  43. epoch = el->epoch;
  44.  
  45. /* Convert FK4 to FK5 catalogue */
  46.  
  47. if( epoch == B1950 )
  48.     {
  49.     fk4fk5( q, m, el );
  50.     goto loop;
  51.     }
  52.  
  53.  
  54. for( i=0; i<3; i++ )
  55.     e[i] = rearth[i];
  56.  
  57. /* precess the earth to the star epoch */
  58. precess( e, epoch, -1 );
  59.  
  60. /* Correct for proper motion and parallax
  61.  */
  62. T = (TDT - epoch)/36525.0;
  63. for( i=0; i<3; i++ )
  64.     {
  65.     p[i] = q[i]  +  T * m[i]  -  el->px * e[i];
  66.     }
  67.  
  68. /* precess the star to J2000 */
  69. precess( p, epoch, 1 );
  70. /* reset the earth to J2000 */
  71. for( i=0; i<3; i++ )
  72.     e[i] = rearth[i];
  73.  
  74. /* Find Euclidean vectors between earth, object, and the sun
  75.  * angles( p, q, e );
  76.  */
  77. angles( p, p, e );
  78.  
  79. /* Find unit vector from earth in direction of object
  80.  */
  81. for( i=0; i<3; i++ )
  82.     {
  83.     p[i] /= EO;
  84.     temp[i] = p[i];
  85.     }
  86.  
  87. if( prtflg )
  88.     {
  89. /* Report astrometric position
  90.  */
  91.     showrd( "Astrometric J2000.0:", p, polar );
  92.  
  93. /* Also in 1950 coordinates
  94.  */
  95.     precess( temp, B1950, -1 );
  96.     showrd( "Astrometric B1950.0:", temp, polar );
  97.  
  98. /* For equinox of date: */
  99.     for( i=0; i<3; i++ )
  100.         temp[i] = p[i];
  101.     precess( temp, TDT, -1 );
  102.     showrd( "Astrometric of date:", temp, polar );
  103.     }
  104.  
  105. /* Correct position for light deflection
  106.  * relativity( p, q, e );
  107.  */
  108. relativity( p, p, e );
  109.  
  110.  
  111. /* Correct for annual aberration
  112.  */
  113. annuab( p );
  114.  
  115. /* Precession of the equinox and ecliptic
  116.  * from J2000.0 to ephemeris date
  117.  */
  118. precess( p, TDT, -1 );
  119.  
  120. /* Ajust for nutation
  121.  * at current ecliptic.
  122.  */
  123. epsiln( TDT );
  124. nutate( TDT, p );
  125.  
  126. /* Display the final apparent R.A. and Dec.
  127.  * for equinox of date.
  128.  */
  129. showrd( "    Apparent:", p, polar );
  130.  
  131. /* Go do topocentric reductions.
  132.  */
  133. dradt = 0.0;
  134. ddecdt = 0.0;
  135. polar[2] = 1.0e38; /* make it ignore diurnal parallax */
  136. altaz( polar, UT );
  137. return(0);
  138. }
  139.